package com.share.common.enums;

import lombok.Getter;

import java.util.LinkedList;
import java.util.List;

@Getter
public enum EventTypeEnum {
    SX("sx", "授信申请", KafkaTopicEnum.CREDIT.code),

    TX("yx", "用信申请", KafkaTopicEnum.LOAN.code),

    YSX("ysx", "预授信", KafkaTopicEnum.PRE_CREDIT.code),

    YTX("yyx", "预用信", KafkaTopicEnum.PRE_LOAN.code);

    private String code;
    private String name;
    private String topic;


    EventTypeEnum(String code, String name, String topic) {
        this.code = code;
        this.name = name;
        this.topic = topic;
    }

    public static EventTypeEnum getEnumByCode(String code) {
        for (EventTypeEnum typeEnum : EventTypeEnum.values()) {
            if (typeEnum.code.equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }

    public static List<String> listCode() {
        List<String> list = new LinkedList<>();
        for (EventTypeEnum typeEnum : EventTypeEnum.values()) {
            list.add(typeEnum.code);
        }
        return list;
    }
}
